package com.qqtech.qquan.mall.service;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;

import com.qqtech.core.frame.dao.BaseDao;
import com.qqtech.core.frame.model.PageKit;
import com.qqtech.core.frame.model.PageOrder;
import com.qqtech.core.frame.service.BaseServiceImpl;
import com.qqtech.qquan.mall.dao.MallBrandDao;
import com.qqtech.qquan.mall.model.*;

@Service
public class MallBrandServiceImpl extends BaseServiceImpl<MallBrand>
		implements MallBrandService {
	public static final Logger log = LoggerFactory.getLogger(MallBrandServiceImpl.class);
	
	@Resource
	private MallBrandDao mallBrandDao;

	@Override
	protected BaseDao<MallBrand> getBaseDao() {
		return mallBrandDao;
	}

	@Override
	public Page<MallBrandVo> queryPageListAdmin(MallBrand query,
			Pageable pageable) {
		return mallBrandDao.queryPageListAdmin(query, pageable);
	}

	/**
	 * 获取categoryId的品牌
	 * @param categoryId
	 * @param status 状态,当status==null时,返回所有状态的
	 * @return
	 */
	@Override
	public List<MallBrandVo> findByCategoryId(String categoryId, Integer status) {
		List<MallBrandVo> list = new ArrayList<MallBrandVo>();
		if (categoryId != null) {
			MallBrandQuery q = new MallBrandQuery();
			q.setCategoryId(categoryId);
			q.setStatus(status);
			Pageable pageKit = new PageKit(1, 9999,
					new PageOrder(Direction.ASC, "firstLetter"));
			list = mallBrandDao.queryList(q, pageKit);
		}
		return list;
	}
	
}